<?php
$this->Html->css('controllers/TestRegister/registered.css?3', array('block' => 'stylesTop'));
$this->Html->script('controllers/TestRegister/registered.js?7', array('block' => 'scriptBottom'));
$appBosch->crud = $this->TioCachas->urlsCRUD();
$appBosch->crud['destroy'] = $this->Html->url(array('action' => 'destroyMasive'));
$appBosch->read = $this->Html->url(array('action' => 'getUsersForTest'));
$appBosch->urlUnscribe = $this->Html->url(array('action' => 'unscribeAll'));
$appBosch->registerAss = $this->Html->url(array('action' => 'registerUsers'));
$appBosch->urlEvaluations = $this->Html->url(array('controller' => 'Evaluations', 'action' => 'saveEvaluations'));
$appBosch->urlEntrenamientos = $this->Html->url(array('controller' => 'Tests', 'action' => 'getTestsByArea', '1'));
$appBosch->urlSchedulesDates = $this->Html->url(array('controller' => 'Schedules', 'action' => 'getTestByDates'));
$appBosch->urlInfoExamen = $this->Html->url(array('controller' => 'Schedules', 'action' => 'getInfoTest'));
$appBosch->urlUserAttempts = $this->Html->url(array('controller' => 'Attempts', 'action' => 'getAttempts'));
$appBosch->cancelSchedule = $this->Html->url(array('controller' => 'TestScheduler', 'action' => 'cancelSchedule'));
$appBosch->urlCreateLogCancel = $this->Html->url(array('controller' => 'TestScheduler', 'action' => 'regLogCancel'));
?>
    <div class="searchEmp sec">
        <form class="form-inline">
            <div class="form-group">
                <label for="start"><?php echo __('Fecha inicial'); ?></label>
                <input type='text' class="form-control" id="start"/>
            </div>
            <div class="form-group">
                <label for="end"><?php echo __('Fecha final'); ?></label>
                <input type='text' class="form-control" id="end"/>
            </div>
            <div class="form-group">
                <label for="closed-filter"><?php echo __('Incluir cursos cerrados'); ?></label>
                <input type='checkbox' class="form-control" id="closed-filter"/>
            </div>
        </form>
    </div>
    <br/>
    <div id="gridSchedules"></div>
    <h3 id="courseName"></h3>
    <div id="detailCourse" class="hidden">
        <div id="regNewUsers">
            <input id="regNomText" class="k-textbox" type="text"
                   placeholder="<?php echo __('Números de nómina separados por espacio. Ej. 99999999 88888888 77777777'); ?>"/>
            <input id="regNomButt" class="k-button k-primary" type="button" value="<?php echo __('Inscribir'); ?>"/>
            <span id="wait" class="k-button hidden">
                <i class="fa fa-spinner fa-spin"></i>
            </span>
        </div>
        <div id="grid"></div>
    </div>
    <script id="windowTemplate" type="text/x-kendo-template">
        # var max = 0; #
        <div>
            <h4><?php echo __('Historial de intentos'); ?></h4>

            <div class="historial">
                <table>
                    <thead>
                    <tr>
                        <th><?php echo __('Calificación'); ?></th>
                        <th><?php echo __('Fecha de aplicación'); ?></th>
                    </tr>
                    </thead>
                    <tbody>
                    # if (res.length == 0) { #
                    <tr>
                        <td><?php echo __('No hay intentos'); ?></td>
                    </tr>
                    <tr>
                        <td><?php echo __(''); ?></td>
                    </tr>
                    # } #
                    # for (var i = 0; i < res.length; i++) {
                    if (parseFloat(res[i].qualification) > parseFloat(max)) {
                    max = res[i].qualification;
                    }
                    if (parseFloat(res[i].qualification) < parseFloat(min_cal)) { #
                    <tr class="reprobado">
                        # } else { #
                    <tr>
                        # } #
                        <td>#= res[i].qualification #</td>
                        <td>#= kendo.toString(new Date(res[i].application_date.replace(/-/g, "/")), "F") #</td>
                    </tr>
                    # } #
                    </tbody>
                </table>
            </div>
            # if ( attempts > res.length) { #
            # if ( parseFloat(max) < parseFloat(min_cal) ) { #
            <h4><?php echo __('Calificar nuevo intento'); ?></h4>

            <div class="controls">
                <input id="valUser" type="hidden" value="#=userId#"/>
                <input id="valTest" type="hidden" value="#=testId#"/>

                <p>
                    <label for="valCalif"><?php echo __('Calificación:'); ?></label>
                    <input id="valCalif" width="70%"/>
                </p>

                <p>
                    <label for="valDate"><?php echo __('Fecha:'); ?></label>
                    <input id="valDate" width="70%"/>
                </p>
            </div>
            <div id="buttonSaveEvaluation" class="k-button" data-ut="#=utId#">Guardar</div>
            # } #
            # } #
        </div>
    </script>

    <script id="windowComment" type="text/x-kendo-template">
        <label class="comm" for="comboComment"><?php echo __('Elige un motivo:'); ?></label>
        <input id="comboComment"/>
        <label class="comm" for="comment"><?php echo __('Ingresa un comentario:'); ?></label>
        <textarea class="comm" id="comment"></textarea>
        <input id="sendComment" class="k-button" type="button" value="<?php echo __('Enviar'); ?>" data-url="#=url#"/>
    </script>

    <script id="dialogAlert" type="text/x-kendo-template">
        <p class="alertMessage" >#=info#</p>
        <div class="baseButton" >
            <input id="aceptButton" class="k-button k-primary" type="button" value="<?php echo __('Aceptar'); ?>"/>
        </div>
    </script>


    <script id="dialogUnsuscribed" type="text/x-kendo-template">
        <p class="" > <?php echo __('Los siguientes usuarios no fueron inscritos:'); ?> </p>
        <div class="historial">
            <table class="table table-bordered table-striped">
                <thead>
                <tr>
                    <th><?php echo __('Nómina'); ?></th>
                    <th><?php echo __('Motivo'); ?></th>
                </tr>
                </thead>
                <tbody>
                # for (var i = 0; i < res.length; i++) { #
                    <tr>
                        <td>#= res[i].nomina #</td>
                        <td>#= res[i].message #</td>
                    </tr>
                # } #
                </tbody>
            </table>
        </div>
        <div class="baseButton" >
            <input id="aceptButton" class="k-button k-primary" type="button" value="<?php echo __('Aceptar'); ?>"/>
        </div>
    </script>

<?php $this->start('jsVars'); ?>
    <script type="text/javascript">
        var appBosch = <?php echo json_encode($appBosch); ?>;
    </script>
<?php $this->end();